import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react-swc';
import tailwindcss from '@tailwindcss/vite';

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [react(), tailwindcss()],
  build: {
    outDir: 'dist/webview',
    rollupOptions: {
      external: [
        'miniprogram-ci',
        'fs',
        'path',
        'crypto',
        'os',
        'child_process',
        'stream',
        'zlib',
        'http',
        'https',
        'url',
        'util',
        'assert',
        'constants',
        'readline'
      ],
      output: {
        entryFileNames: 'index.js',
        assetFileNames: 'index.css',
      },
    },
  },
  resolve: {
    alias: {
      '@': '/src/webview',
    },
  },
  server: {
    port: 3000,
    host: 'localhost',
    open: false,
  },
});
